﻿using BasicData.Application.Input;
using BasicData.Application.Input.Workshop;
using BasicData.Application.Output;
using BasicData.Application.Services.Workshop;
using BasicData.Domain.Entities;
using BasicData.Result;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using StackExchange.Redis;

namespace BasicData.Api.Controllers
{
    ///<summary>
    /// 车间管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
   
    public class WorkshopController : ControllerBase
    {
        IWorkshopServices services;
        ILogger<WorkshopController> logger;

        public WorkshopController(IWorkshopServices services, ILogger<WorkshopController> logger)
        {
            this.services = services;
            this.logger = logger;
        }
        /// <summary>
        /// 添加车间
        /// </summary>
        [HttpPost]
       
        public ApiResult<int> AddWorkshop(WorkshopInput input)
        {
            logger.LogInformation("添加车间");
            return services.AddWorkshop(input);
        }
        /// <summary>
        /// 获取车间
        /// </summary>
        [HttpGet]
        
        public ApiResult<WorkshopOutput> GetWorkshop([FromQuery]PageInput input)
        {
            logger.LogInformation("获取车间");
            return services.GetWorkshop(input);
        }
        /// <summary>
        /// 修改车间
        /// </summary>
        [HttpPut]
       
        public ApiResult<int> UpdateWorkshop(UpdateWorkshopInput input)
        {
            logger.LogInformation("修改车间");
            return services.UpdateWorkshop(input);
        }
        /// <summary>
        /// 删除车间
        /// </summary>
        [HttpPut]
        
        public ApiResult<int> DeleteWorkshop(long id)
        {
            logger.LogInformation("删除车间");
            return services.DeleteWorkshop(id);
        }
        /// <summary>
        /// 显示所有车间
        /// </summary>
        [HttpGet]
       
        public ApiResult<List<WorkshopOutput>> ShowWorkshop()
        {
            return services.ShowWorkshop();
        }
        
    }
}
